package com._119yn.host.gst200.cansocket.codec;

import com._119yn.host.gst200.cansocket.message.Pong;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class PongDecoder extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof String s) {
            if (s.equals("pong")) {
                ctx.fireChannelRead(Pong.INSTANCE);
            } else {
                ctx.fireChannelRead(msg);
            }
        }
    }

}
